package com.uzai.console.web.main;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.dto.main.main.RechargeDto;
import com.uzai.console.dto.main.main.TakeBalDto;
import com.uzai.console.dto.main.notice.NoticeIdDto;
import com.uzai.console.dto.main.notice.NoticeQuery;
import com.uzai.console.dto.main.updatelog.UpdateLogIdDto;
import com.uzai.console.dto.main.updatelog.UpdateLogQuery;
import com.uzai.console.entity.DingExclusiveGroupConfig;
import com.uzai.console.entity.UserTakeBal;
import com.uzai.console.service.main.MainService;
import com.uzai.console.service.main.NoticeService;
import com.uzai.console.service.main.UpdateLogService;
import com.uzai.console.vo.main.main.*;
import com.uzai.console.vo.main.notice.NoticeInfoVo;
import com.uzai.console.vo.main.updatelog.UpdateLogInfoVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 登录日志
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "主页",tags = "控制台|主页")
@ApiSort(3)
@RestController
public class MainController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(MainController.class);

    @Autowired
    private NoticeService noticeService;
    @Autowired
    private UpdateLogService updateLogService;
    @Autowired
    private MainService mainService;

    @ApiOperation(value = "查询公告列表", notes = "查询公告信息列表", response = NoticeInfoVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/main/findNoticeList")
    public Object findNoticeList(@RequestBody NoticeQuery noticeQuery){
        return noticeService.findNoticeList(noticeQuery);
    }

    @ApiOperation(value = "查询公告详情", notes = "查询公告详情", response = NoticeInfoVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/main/findNoticeInfo")
    public Object findNoticeInfo(@RequestBody NoticeIdDto noticeIdDto){
        //添加已读记录
        noticeService.firstReadNotice(getLoginInfo().getMerId(), noticeIdDto.getId());
        //返回公告信息
        return noticeService.findNoticeInfo(noticeIdDto);
    }

    @ApiOperation(value = "查询更新日记列表", notes = "查询更新日记列表", response = NoticeInfoVo.class)
    @ApiOperationSupport(order = 3)
    @PostMapping("/main/findUpdateLogList")
    public Object findUpdateLogList(@RequestBody UpdateLogQuery updateLogQuery){
        return updateLogService.findUpdateLogList(updateLogQuery);
    }

    @ApiOperation(value = "查询公告详情", notes = "查询公告详情", response = UpdateLogInfoVo.class)
    @ApiOperationSupport(order = 4)
    @PostMapping("/main/findUpdateLogInfo")
    public Object findUpdateLogInfo(@RequestBody UpdateLogIdDto updateLogIdDto){
        //返回公告信息
        return updateLogService.findUpdateLogInfo(updateLogIdDto);
    }

    @ApiOperation(value = "查询账户余额", notes = "查询账户余额", response = BalanceVo.class)
    @ApiOperationSupport(order = 5)
    @PostMapping("/main/findBalance")
    public Object findBalance(){
        return mainService.findBalance(getLoginInfo().getMerId());
    }

    @ApiOperation(value = "账户充值", notes = "账户充值", response = RechargeVo.class)
    @ApiOperationSupport(order = 5)
    @PostMapping("/main/recharge")
    public Object recharge(@RequestBody RechargeDto rechargeDto){
        return mainService.recharge(rechargeDto);
    }

    @ApiOperation(value = "账户余额提现", notes = "账户提现", response = Boolean.class)
    @ApiOperationSupport(order = 5)
    @PostMapping("/main/takeBal")
    public Object takeBal(@RequestBody TakeBalDto takeBalDto){
        mainService.takeBal(takeBalDto);
        return true;
    }

    @ApiOperation(value = "查询机器人数", notes = "查询机器人数", response = DeviceCountVo.class)
    @ApiOperationSupport(order = 6)
    @PostMapping("/main/findDeviceCount")
    public Object findDeviceCount(){
        return mainService.findDeviceCount(getLoginInfo().getMerId());
    }

    @ApiOperation(value = "数据统计(预估利润、有效订单、新增会员、提现金额)", notes = "数据统计(预估利润、有效订单、新增会员、提现金额)", response = ProfitVo.class)
    @ApiOperationSupport(order = 7)
    @PostMapping("/main/findProfit")
    public Object findProfit(){
        return mainService.findProfitV2(getLoginInfo().getMerId());
    }

//
//    @ApiOperation(value = "查询新增会员", notes = "查询新增会员", response = UserAddVo.class)
//    @ApiOperationSupport(order = 8)
//    @PostMapping("/main/findUserAdd")
//    public Object findUserAdd(){
//        return mainService.findUserAdd(getLoginInfo().getMerId());
//    }
//
//    @ApiOperation(value = "查询提现金额", notes = "查询提现金额", response = UserTakeBal.class)
//    @ApiOperationSupport(order = 9)
//    @PostMapping("/main/findUserTakeBal")
//    public Object findUserTakeBal(){
//        return mainService.findUserTakeBal(getLoginInfo().getMerId());
//    }

    @ApiOperation(value = "查询授权模块数据", notes = "查询授权模块数据", response = TokenVo.class)
    @ApiOperationSupport(order = 10)
    @PostMapping("/main/findTokenExpired")
    public Object findTokenExpired(){
        return mainService.findTokenExpired(getLoginInfo().getMerId());
    }

    @ApiOperation(value = "查询功能模块数据", notes = "查询功能模块数据", response = ProductExpiredVo.class)
    @ApiOperationSupport(order = 11)
    @PostMapping("/main/findProductExpired")
    public Object findProductExpired(){
        return mainService.findProductExpired(getLoginInfo().getMerId());
    }

    @ApiOperation(value = "查询机器人授权模块（即将到期、掉线）", notes = "查询机器人授权模块（即将到期、掉线）", response = DeviceExpiredVo.class)
    @ApiOperationSupport(order = 12)
    @PostMapping("/main/findDeviceExpired")
    public Object findDeviceExpired(){
        return mainService.findDeviceExpired(getLoginInfo().getMerId());
    }

    @ApiOperation(value = "查询好友请求数", notes = "查询好友请求数", response = FriendRequestVo.class)
    @ApiOperationSupport(order = 13)
    @PostMapping("/main/findFrindRequestCount")
    public Object findFrindRequestCount(){
        return mainService.findFrindRequestCount(getLoginInfo().getMerId());
    }


    @ApiOperation(value = "查询钉钉专属服务群二维码", notes = "查询钉钉专属服务群二维码", response = DingExclusiveGroupConfig.class)
    @ApiOperationSupport(order = 14)
    @PostMapping("/main/queryDingDingExclusiveGroupQrCode")
    public Object queryDingDingExclusiveGroupQrCode(){
        DingExclusiveGroupConfig dingExclusiveGroupConfig = mainService.queryDingDingExclusiveGroupQrCode(getLoginInfo().getMerId());
        return  dingExclusiveGroupConfig;
    }

    @ApiOperation(value = "判断运营商是否加钉钉专属服务群", notes = "判断运营商是否加钉钉专属服务群", response = boolean.class)
    @ApiOperationSupport(order = 15)
    @PostMapping("/main/ifJoinDingDingExclusiveGroup")
    public Object ifJoinDingDingExclusiveGroup(){
    return true;
    }

}
